import React from 'react'

class Form extends React.Component {
    constructor(props) {
        super(props);

        this.state = {
            value : ''
        }
    }

    handleChange(e) {
        this.setState({
            value : e.target.value
        })
    }

    handleSubmit(e) {
        e.preventDefault();
        console.log(this.state.value)
    }

    render() {
        return (
            <form  onSubmit={this.handleSubmit.bind(this)}>
                <label htmlFor="sb">
                    Name:
                    <input id="sb" type="text" value={ this.state.value } onChange={this.handleChange.bind(this)} />
                </label>
                <input type="submit" name="" value="Submit" />
                <div>
                    { this.state.value }
                </div>
            </form>
        )
    }
}

export default Form